<?php
define ( "LIWE_MOD_KERNEL", 1 );
define ( "LIWE_MOD_BASE", 2 );
define ( "LIWE_MOD_DOM", 3 );
define ( "LIWE_MOD_EXTRAS", 4 );

class liwe
{
	function liwe ( & $layman, $base_dir = "os3jslib" )
	{
		$this->layman = & $layman;
		$this->base_dir = $base_dir;

		$this->modules = array ( 
			LIWE_MOD_KERNEL => array (
					array ( "liwe", "liwe", 1, null ),
					array ( "history", "liwe.history", 1, null ),
					),

			LIWE_MOD_BASE => array (
					array ( "utils", "liwe.utils.max", 1, null ),
					array ( "locale", "liwe.locale", 1, null ),
					array ( "form", "liwe.form", 1, null ),
					array ( "validators", "liwe.validators", 1, null ),
					array ( "json", "Object.prototype.toJSONString", 1, null ),
					array ( "object_enh", "Object.prototype.debugDump", 1, null ),
					array ( "string_enh", "String.prototype.startsWith", 1, null ),
					array ( "array_enh", "Array.prototype.toSourceString", 1, null ),
					array ( "ajax_manager", "liwe.AJAX", 1, null )
				),

			LIWE_MOD_DOM => array (
					array ( "dom", "liwe.dom", 3, null ),
					array ( "fx", "liwe.fx.set_opacity", 3, null ),
					array ( "fx/fade", "liwe.fx.fade_in", 9, null ),
					array ( "lightbox", "liwe.lightbox", 3, null ),
			),

			LIWE_MOD_EXTRAS => array (
					array ( "md5", "MD5", 3, null ),
					array ( "money", "Money", 3, null ),
					array ( "testers", "isAlien", 3, null ),
			),


			);

		$this->add_module ( LIWE_MOD_KERNEL, 0 );
	}
	
	function add_module ( $module, $postload = true )
	{
		$mod = $this->modules [ $module ];

		foreach ( $mod as $val )
		{
			if ( $postload )
				$this->layman->add_js_post ( $this->base_dir . "/" . $val [ 0 ] . ".js", $val [ 1 ], $val [ 2 ], $val [ 3 ] );
			else
				$this->layman->add_js ( $this->base_dir . "/" . $val [ 0 ] . ".js" );
		}
	}
}
?>
